<?php

class Damages_Methods_Data_CarDamage {

  /**
   *
   * @var int 
   */
  public $id;

  /**
   *
   * @var Damages_Methods_Data_Processes_ProcessType 
   */
  public $process;

  /**
   *
   * @var Damages_Methods_Data_CarData 
   */
  public $carData;

  /**
   *
   * @var Damages_Methods_Data_Dictionary_Status
   */
  public $status;

  /**
   *
   * @var Damages_Methods_Data_Dictionary_Perpetrator 
   */
  public $perpetrator;

  /**
   *
   * @var int 
   */
  public $relatedCarDamageId;

  /**
   *
   * @var Damages_Methods_Data_User 
   */
  public $ls;

  /**
   *
   * @var Damages_Methods_Data_User 
   */
  public $ol;

  /**
   *
   * @var string
   */
  public $damageDate;

  /**
   *
   * @var string
   */
  public $dealerReportDate;

  /**
   *
   * @var string
   */
  public $perpetratorReportDate;

  /**
   *
   * @var Damages_Methods_Data_Damage[]
   */
  public $damages = array();

  /**
   *
   * @var string
   */
  public $damageDescription;

  /**
   *
   * @var string
   */
  public $description;

  /**
   *
   * @var Damages_Methods_Data_Note[] 
   */
  public $notes = array();

  /**
   *
   * @var Damages_Methods_Data_Invoice[] 
   */
  public $invoices = array();

  /**
   *
   * @var Damages_Methods_Data_EstimatedBudget[] 
   */
  public $estimatedBudgets = array();

  /**
   *
   * @var Damages_Methods_Data_Attachments 
   */
  public $attachments;

  /**
   *
   * @var Damages_Methods_Data_Discard 
   */
  public $discard;

  /**
   *
   * @var string 
   */
  public $created;

  /**
   *
   * @var string 
   */
  public $modified;

  public function __construct(DamagesCarDamages $obj) {
    $this->id = $obj->getId();
    $this->carData = new Damages_Methods_Data_CarData($obj->getCarData());
    $this->status = new Damages_Methods_Data_Dictionary_Status($obj->getDictStatuses());
    $this->perpetrator = new Damages_Methods_Data_Dictionary_Perpetrator($obj->getDictPerpetrators());
    $this->process = new Damages_Methods_Data_Processes_ProcessType($obj->getProcessTypes(), true);
    if ($obj->getRelatedCarDamage() && in_array(Damages_Auth::getInstance()->getUser()->getPermissions()->getCode(), array(Damages_Auth::PERMISSION_ADMIN, Damages_Auth::PERMISSION_LS)))
      $this->process->setDisplayedProcess($obj->getCarDamagesRelatedByRelatedCarDamage()->getProcessTypes());
    $this->relatedCarDamageId = $obj->getRelatedCarDamage();
    if ($obj->getLsId())
      $this->ls = new Damages_Methods_Data_User($obj->getUsersRelatedByLsId(), true);
    if ($obj->getOlId())
      $this->ol = new Damages_Methods_Data_User($obj->getUsersRelatedByOlId(), true);
    $this->damageDate = $obj->getDamageDate();
    $this->dealerReportDate = $obj->getDealerReportDate();
    $this->perpetratorReportDate = $obj->getPerpetratorReportDate();
    $this->damageDescription = $obj->getDamagesDescription();
    $this->description = $obj->getDescription();
    $this->created = $obj->getCreated();
    $this->modified = $obj->getModified();
    $this->attachments = new Damages_Methods_Data_Attachments();
    foreach ($obj->getAttachmentss() as $attachment) {
      $this->attachments->addAttachmentData($attachment);
    }
    foreach ($obj->getEstimatedBudgetss() as $estimatedBudget) {
      $this->estimatedBudgets[] = new Damages_Methods_Data_EstimatedBudget($estimatedBudget);
    }
    foreach ($obj->getInvoicess() as $invoice) {
      $this->invoices[] = new Damages_Methods_Data_Invoice($invoice);
    }
    foreach ($obj->getNotess() as $note) {
      $this->notes[] = new Damages_Methods_Data_Note($note);
    }
    if ($obj->getDiscardId())
      $this->discard = new Damages_Methods_Data_Discard($obj);
    foreach ($obj->getDamagess() as $damage) {
      $this->damages[] = new Damages_Methods_Data_Damage($damage);
    }
  }

}